package com.bix.util.blizfiles.m2;

import java.nio.ByteBuffer;

/**
 * Many values in the M2 file format are references to other positions in the
 * file.  These references are in the format of count:32,offset:32.  This class
 * encapsulates information about these types of references.
 * 
 * @author	squid
 *
 * @version	1.0.0
 */
public class M2CountOffsetPair {
	private	int	count;
	private	int	offset;
	
	public M2CountOffsetPair () {
		this (0, 0);
	}
	
	public M2CountOffsetPair (ByteBuffer bb) {
		read (bb);
	}
	
	public M2CountOffsetPair (int count, int offset) {
		this.count = count;
		this.offset = offset;
	}
	
	public void read (ByteBuffer bb) {
		this.count = bb.getInt ();
		this.offset = bb.getInt ();
	}
	
	public byte[] readBytes (ByteBuffer bb) {
		byte[]	data = new byte[this.count];
		bb.position (this.offset);
		bb.get(data);
		return data;
	}

	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}

	/**
	 * @return the offset
	 */
	public int getOffset() {
		return offset;
	}
}